import XLSX from 'xlsx'

import FileSaver from 'file-saver'

// domName 是 表格的 ref , sheet

export const exportExcel = (domName, sheetName) => {

    const worksheet = XLSX.utils.table_to_sheet(domName.$el)

    const workbook = XLSX.utils.book_new()

    XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1')

    const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' })

    const data = new Blob([excelBuffer], { type: 'application/octet-stream' })

    FileSaver.saveAs(data, sheetName + '.xlsx')

}
